package com.ruoyi.web.controller.share;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.share.domain.ShareGoodsRemarks;
import com.ruoyi.share.service.IShareGoodsRemarksService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商品备注Controller
 *
 * @author ruoyi
 * @date 2021-11-16
 */
@RestController
@RequestMapping("/api/shoreremarks")
public class ShareGoodsRemarksController extends BaseController
{
    @Autowired
    private IShareGoodsRemarksService shareGoodsRemarksService;

    /**
     * 查询商品备注列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ShareGoodsRemarks shareGoodsRemarks)
    {
        startPage();
        List<ShareGoodsRemarks> list = shareGoodsRemarksService.selectShareGoodsRemarksList(shareGoodsRemarks);
        return getDataTable(list);
    }

    /**
     * 导出商品备注列表
     */
    @GetMapping("/export")
    public AjaxResult export(ShareGoodsRemarks shareGoodsRemarks)
    {
        List<ShareGoodsRemarks> list = shareGoodsRemarksService.selectShareGoodsRemarksList(shareGoodsRemarks);
        ExcelUtil<ShareGoodsRemarks> util = new ExcelUtil<ShareGoodsRemarks>(ShareGoodsRemarks.class);
        return util.exportExcel(list, "商品备注数据");
    }

    /**
     * 获取商品备注详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(shareGoodsRemarksService.selectShareGoodsRemarksById(id));
    }

    /**
     * 新增商品备注
     */
    @PostMapping
    public AjaxResult add(@RequestBody ShareGoodsRemarks shareGoodsRemarks)
    {
        return toAjax(shareGoodsRemarksService.insertShareGoodsRemarks(shareGoodsRemarks));
    }

    /**
     * 修改商品备注
     */
    @PutMapping
    public AjaxResult edit(@RequestBody ShareGoodsRemarks shareGoodsRemarks)
    {
        return toAjax(shareGoodsRemarksService.updateShareGoodsRemarks(shareGoodsRemarks));
    }

    /**
     * 删除商品备注
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shareGoodsRemarksService.deleteShareGoodsRemarksByIds(ids));
    }
}
